package com.mo.axion.web.controller;

import com.alibaba.fastjson.JSON;
import com.ctrip.framework.apollo.Config;
import com.ctrip.framework.apollo.ConfigService;
import com.mo.axion.handler.utils.GroupIdMappingUtils;
import com.mo.axion.service.api.impl.action.send.SendAssembleAction;
import com.mo.axion.service.api.impl.action.send.SendPreCheckAction;
import com.mo.axion.support.dao.MessageTemplateDao;
import com.mo.axion.support.domain.MessageTemplate;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author Mo
 * @createTime 2024/1/24 1:02
 * @description 测试用
 */
@Slf4j
@RestController
@RequestMapping("/test")
public class TestController {
    @Autowired
    private MessageTemplateDao messageTemplateDao;

    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    @RequestMapping("/test")
    private String test() {
        System.out.println("这是测试接口哟");
        log.info("测试日志");
        System.out.println(GroupIdMappingUtils.getAllGroupIdList());
        return "测试成功";
    }

    @RequestMapping("/database")
    private String testDataBase() {
        List<MessageTemplate> list = messageTemplateDao.findAllByIsDeletedEqualsOrderByUpdatedDesc(0, PageRequest.of(0, 10));
        return JSON.toJSONString(list);
    }

    @RequestMapping("/redis")
    private String testRedis() {
        stringRedisTemplate.opsForValue().set("mo", "axion");
        return stringRedisTemplate.opsForValue().get("mo");
    }

//    @RequestMapping("/getConfig")
//    private String testGetConfig() {
//        Config appConfig = ConfigService.getAppConfig();
//        String property = appConfig.getProperty("boss.austin", null);
//        System.out.println(property);
//        return property;
//    }
}





